#coding=utf-8
#此脚本全部为函数，方便直接调用进行自动化测试
from selenium import webdriver
import time, datetime
import os
import sys
from selenium.webdriver.support.select import Select
from selenium.webdriver.common.keys import Keys


#发车易贷
def op_che(url, adminname, password,borrow_type,borrow_type1, borrowtitle, money, huankuanfangshi, rate, username_type, borrowname, month, cashgroup, agentname,biaofenpei, rewardstate, rewardmode, reward):
    # 定义浏览器及地址
    reload(sys)
    sys.setdefaultencoding('utf-8')
    driver = webdriver.Chrome()
    driver.maximize_window()
    driver.implicitly_wait(8)
    driver.get(url)
    #进行登录co环境的运营平台
    driver.find_element_by_id("adminname").send_keys(adminname)
    driver.find_element_by_id("password").send_keys(password)
    driver.find_element_by_id("authCode").send_keys(u"1234")
    driver.find_element_by_xpath(".//*[@id='submitFrom']/ul/li[4]/input").click()
    #判断是否登录成功，并输出至日志登录账号名称
    try:
        driver.find_element_by_xpath(".//*[@id='header']/section[1]/div/aside/em")
        a = True
    except:
        a = False
    if a == True:
        username = driver.find_element_by_xpath(".//*[@id='header']/section[1]/div/aside/em").text
        #进入发标页面
        driver.find_element_by_link_text(u"标的管理").click()
        driver.find_element_by_xpath(".//*[@id='subnav']/dl/dd[4]/a").click()
        #第一个页面
        driver.find_element_by_xpath(".//*[@id='form1']/ul[1]/li[1]/aside/label["+borrow_type+"]/input").click()  #选择1为普通标，选择2为定向标
        driver.find_element_by_xpath(".//*[@id='form1']/ul[1]/li[2]/aside/label["+borrow_type1+"]/input").click() #选择标种类型
        now = time.strftime("%Y%m%d%H%M%S", time.localtime(time.time()))  # 标的编号命名格式
        driver.find_element_by_xpath(".//*[@id='form1']/ul[1]/li[3]/aside/input").send_keys(now)
        driver.find_element_by_xpath(".//*[@id='borrow_numbers']").send_keys(now)
        driver.find_element_by_xpath(".//*[@id='form1']/ul[1]/li[5]/aside/input").send_keys(borrowtitle + now)
        Select(driver.find_element_by_id("username_type")).select_by_visible_text(username_type)
        driver.find_element_by_id("username").send_keys(borrowname)
        #driver.find_element_by_xpath(".//*[@id='form1']/ul[1]/li[5]/h6").click()
        #为普通标时
        if borrow_type == u"1":


                #为车易贷时
                if borrow_type1 == u"1":
                    if username_type == u"机构":
                        #driver.find_element_by_id("weituo_ren").send_keys(u"511324199412270492")
                        #driver.find_element_by_id("wtUpload").send_keys("D:\\photo\\1.jpg")
                        Select(driver.find_element_by_id("borrow_use")).select_by_visible_text(u"临时周转")
                        driver.find_element_by_id("account").send_keys(money)
                        driver.find_element_by_xpath(".//*[@id='borrow_style_box']/label[" + huankuanfangshi + "]/input").click()
                        Select(driver.find_element_by_id("borrow_period")).select_by_visible_text(month)
                        time.sleep(2)
                        driver.find_element_by_id("borrow_apr").clear()
                        driver.find_element_by_id("borrow_apr").send_keys(rate)
                        Select(driver.find_element_by_xpath(".//*[@id='cashgroup']")).select_by_visible_text(cashgroup)
                        driver.find_element_by_id("agent_username").send_keys(agentname)
                        driver.find_element_by_link_text(u"下一步").click()
                        # driver.find_element_by_xpath(".//*[@id='form1']/ul/li[6]/aside/input").send_keys(u"陈强")
                        Select(driver.find_element_by_id("category")).select_by_visible_text(u"其他")
                        driver.find_element_by_id("account_use").send_keys(u"借钱来耍耍")
                        driver.find_element_by_link_text(u"下一步").click()
                        driver.switch_to_alert().accept()
                    if username_type == u"个人":
                        Select(driver.find_element_by_id("borrow_use")).select_by_visible_text(u"临时周转")
                        driver.find_element_by_id("account").send_keys(money)
                        driver.find_element_by_xpath(".//*[@id='borrow_style_box']/label[" + huankuanfangshi + "]/input").click()
                        Select(driver.find_element_by_id("borrow_period")).select_by_visible_text(month)
                        time.sleep(2)
                        driver.find_element_by_id("borrow_apr").clear()
                        driver.find_element_by_id("borrow_apr").send_keys(rate)
                        Select(driver.find_element_by_xpath(".//*[@id='cashgroup']")).select_by_visible_text(cashgroup)
                        driver.find_element_by_id("agent_username").send_keys(agentname)
                        driver.find_element_by_link_text(u"下一步").click()
                        driver.switch_to_alert().accept()
                        # 第二个页面
                        Select(driver.find_element_by_id("edu")).select_by_visible_text(u"本科")
                        driver.find_element_by_xpath(".//*[@id='form1']/ul[2]/li[6]/aside/label[1]/input").click()
                        driver.find_element_by_xpath(".//*[@id='form1']/ul[2]/li[7]/aside/input").send_keys(u"四川省南充市")
                        driver.find_element_by_xpath(".//*[@id='form1']/ul[2]/li[8]/aside/input").send_keys(u"四川省成都市青羊区")
                        Select(driver.find_element_by_id("category")).select_by_visible_text(u"其他")
                        driver.find_element_by_id("account_use").send_keys(u"借钱来耍耍")
                        Select(driver.find_element_by_id("province")).select_by_visible_text(u"四川省")
                        Select(driver.find_element_by_id("city")).select_by_visible_text(u"成都")
                        driver.find_element_by_id("work_info").send_keys(u"工作很好，工资很高")
                        driver.find_element_by_link_text(u"下一步").click()
                    driver.find_element_by_xpath(".//*[@id='car']/li[2]/aside/label[1]/input").click()
                    driver.find_element_by_xpath(".//*[@id='car']/li[3]/aside/label[1]/input").click()
                    driver.find_element_by_xpath(".//*[@id='car']/li[7]/aside/input").send_keys(u"100")
                    driver.find_element_by_xpath(".//*[@id='car']/li[12]/aside/input").send_keys(now)
                    driver.find_element_by_xpath(".//*[@id='form1']/ul[6]/li[5]/aside/input[5]").click()
                    driver.find_element_by_link_text(u"提交").click()
                    # 判断是否发布标的成功
                    # 进入标的批次号管理页面查看是否发布成功
                    driver.find_element_by_xpath(".//*[@id='subnav']/dl/dd[22]/a").click()
                    Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"业务编号")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(now)
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[2]/a").click()
                    try:
                        driver.find_element_by_xpath(".//*[@id='yfm']")
                        b = True
                    except:
                        b = False
                    if b == True:
                        text = driver.find_element_by_xpath(".//*[@id='yfm']").text
                        borrowid = driver.find_element_by_xpath(".//*[@id='tabScroll']/div/table/tbody/tr/td[2]").text
                        driver.find_element_by_xpath(".//*[@id='tabScroll']/div/table/tbody/tr[1]/td[1]/input").click()  # 勾选第一个标的进行生成批次号
                        driver.find_element_by_xpath("html/body/main/section/div[2]/a").click()
                        time.sleep(2)
                        driver.find_element_by_xpath(".//*[@id='form_yhk']/ul/li[4]/input[1]").click()
                        time.sleep(2)
                        driver.find_element_by_xpath(".//*[@id='form_yhk']/ul/li[3]/input[2]").click()
                        # 再次搜索对应用户名的标
                        Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"业务编号")
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(now)
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[2]/a").click()
                        driver.find_element_by_xpath(".//*[@id='tabScroll']/div/table/tbody/tr/td[1]/input").click()
                        driver.find_element_by_xpath("html/body/main/section/div[2]/a[2]").click()
                        time.sleep(2)
                        driver.find_element_by_xpath(u"(//input[@value='确定'])[2]").click()
                        driver.refresh()
                        # 进入标的初审页面,并按照借款编号进行搜索标的
                        time.sleep(2)
                        driver.find_element_by_xpath(".//*[@id='subnav']/dl/dd[5]/a").click()
                        Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"借款编号")
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(borrowid)
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                        # 进入初审页面
                        driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr/td/a[1]").click()
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/aside/label[1]/input").click()
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[2]/aside/textarea").send_keys(u"审核审核")
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[3]/aside/span[1]/a").click()
                        time.sleep(3)
                        Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"借款编号")
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(borrowid)
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                        # 提交二审
                        driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr[1]/td/a[1]").click()
                        driver.find_element_by_xpath(".//*[@id='form1']/ul[3]/li/aside/span[1]/a").click()
                        time.sleep(3)
                        Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"借款编号")
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(borrowid)
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                        driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr/td/a[1]").click()
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/aside/label[1]/input").click()
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[2]/aside/textarea").send_keys(u"审核审核")
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[3]/aside/span[1]/a").click()
                        # 执行发标连接，进入投资中的借款
                        driver.get("http://task.yidai.co/worthautoissue.task.php")
                        time.sleep(2)
                        driver.refresh()
                        driver.quit()
                        return u"借款标题是：" + borrowtitle + now + u",借款人是：" + borrowname + u"，借款编号是：" + borrowid
                    if b == False:
                        driver.quit()
                        return u"发标失败"
                if a == False:
                    driver.quit()
                    return u"登录失败"
                #为房易贷时
                if borrow_type1 == u"2":
                    if username_type == u"机构":
                        #driver.find_element_by_id("weituo_ren").send_keys(u"511324199412270492")
                        #driver.find_element_by_id("wtUpload").send_keys("D:\\photo\\1.jpg")
                        Select(driver.find_element_by_id("borrow_use")).select_by_visible_text(u"临时周转")
                        driver.find_element_by_id("account").send_keys(money)
                        driver.find_element_by_xpath(".//*[@id='borrow_style_box']/label[" + huankuanfangshi + "]/input").click()
                        Select(driver.find_element_by_id("borrow_period")).select_by_visible_text(month)
                        time.sleep(2)
                        driver.find_element_by_id("borrow_apr").clear()
                        driver.find_element_by_id("borrow_apr").send_keys(rate)
                        Select(driver.find_element_by_xpath(".//*[@id='cashgroup']")).select_by_visible_text(cashgroup)
                        driver.find_element_by_id("agent_username").send_keys(agentname)
                        driver.find_element_by_link_text(u"下一步").click()
                        # driver.find_element_by_xpath(".//*[@id='form1']/ul/li[6]/aside/input").send_keys(u"陈强")
                        Select(driver.find_element_by_id("category")).select_by_visible_text(u"其他")
                        driver.find_element_by_id("account_use").send_keys(u"借钱来耍耍")
                        driver.find_element_by_link_text(u"下一步").click()
                        driver.switch_to_alert().accept()
                    if username_type == u"个人":
                        Select(driver.find_element_by_id("borrow_use")).select_by_visible_text(u"临时周转")
                        driver.find_element_by_id("account").send_keys(money)
                        driver.find_element_by_xpath(".//*[@id='borrow_style_box']/label[" + huankuanfangshi + "]/input").click()
                        Select(driver.find_element_by_id("borrow_period")).select_by_visible_text(month)
                        time.sleep(2)
                        driver.find_element_by_id("borrow_apr").clear()
                        driver.find_element_by_id("borrow_apr").send_keys(rate)
                        Select(driver.find_element_by_xpath(".//*[@id='cashgroup']")).select_by_visible_text(cashgroup)
                        driver.find_element_by_id("agent_username").send_keys(agentname)
                        driver.find_element_by_link_text(u"下一步").click()
                        driver.switch_to_alert().accept()
                        # 第二个页面
                        Select(driver.find_element_by_id("edu")).select_by_visible_text(u"本科")
                        driver.find_element_by_xpath(".//*[@id='form1']/ul[2]/li[6]/aside/label[1]/input").click()
                        driver.find_element_by_xpath(".//*[@id='form1']/ul[2]/li[7]/aside/input").send_keys(u"四川省南充市")
                        driver.find_element_by_xpath(".//*[@id='form1']/ul[2]/li[8]/aside/input").send_keys(u"四川省成都市青羊区")
                        Select(driver.find_element_by_id("category")).select_by_visible_text(u"其他")
                        driver.find_element_by_id("account_use").send_keys(u"借钱来耍耍")
                        Select(driver.find_element_by_id("province")).select_by_visible_text(u"四川省")
                        Select(driver.find_element_by_id("city")).select_by_visible_text(u"成都")
                        driver.find_element_by_id("work_info").send_keys(u"工作很好，工资很高")
                        driver.find_element_by_link_text(u"下一步").click()
                    # 进入发标第三个页面
                    # 切换iframe
                    driver.switch_to.frame("iframebox1")
                    Select(driver.find_element_by_xpath(".//*[@id='house_type']")).select_by_visible_text(u"商品房")
                    driver.find_element_by_xpath(".//*[@id='house']/li[3]/aside/label[1]/input").click()
                    driver.find_element_by_xpath(".//*[@id='house']/li[5]/aside/input").send_keys(u"2015-07-25")
                    driver.find_element_by_xpath(".//*[@id='house']/li[6]/aside/input").send_keys(u"100")
                    driver.find_element_by_xpath(".//*[@id='house']/li[8]/aside/input").send_keys(u"成都市公证处")
                    driver.find_element_by_id("house_money").send_keys(u"100")
                    driver.find_element_by_id("house_area").send_keys(u"100")
                    driver.find_element_by_id("house_address").send_keys(u"成都市天府广场")
                    driver.find_element_by_id("house_byuser").send_keys(u"陈强")
                    Select(driver.find_element_by_id("house_byuser_type")).select_by_visible_text(u"单独所有")
                    driver.find_element_by_xpath(".//*[@id='house']/li[14]/aside/input").send_keys(now)
                    driver.switch_to.default_content()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul[2]/li[5]/aside/input[6]").click()
                    time.sleep(2)
                    driver.find_element_by_xpath(".//*[@id='form1']/ul[3]/li/aside/span[1]/a").click()
                    # 判断是否发布标的成功
                    # 进入标的批次号管理页面查看是否发布成功
                    driver.find_element_by_xpath(".//*[@id='subnav']/dl/dd[22]/a").click()
                    Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"业务编号")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(now)
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[2]/a").click()
                    try:
                        driver.find_element_by_xpath(".//*[@id='yfm']")
                        b = True
                    except:
                        b = False
                    if b == True:
                        text = driver.find_element_by_xpath(".//*[@id='yfm']").text
                        borrowid = driver.find_element_by_xpath(".//*[@id='tabScroll']/div/table/tbody/tr/td[2]").text
                        driver.find_element_by_xpath(
                            ".//*[@id='tabScroll']/div/table/tbody/tr[1]/td[1]/input").click()  # 勾选第一个标的进行生成批次号
                        driver.find_element_by_xpath("html/body/main/section/div[2]/a").click()
                        time.sleep(2)
                        driver.find_element_by_xpath(".//*[@id='form_yhk']/ul/li[4]/input[1]").click()
                        time.sleep(2)
                        driver.find_element_by_xpath(".//*[@id='form_yhk']/ul/li[3]/input[2]").click()
                        # 再次搜索对应用户名的标
                        Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"业务编号")
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(now)
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[2]/a").click()
                        driver.find_element_by_xpath(".//*[@id='tabScroll']/div/table/tbody/tr/td[1]/input").click()
                        driver.find_element_by_xpath("html/body/main/section/div[2]/a[2]").click()
                        time.sleep(2)
                        driver.find_element_by_xpath(u"(//input[@value='确定'])[2]").click()
                        driver.refresh()
                        # 进入标的初审页面,并按照借款编号进行搜索标的
                        time.sleep(2)
                        driver.find_element_by_xpath(".//*[@id='subnav']/dl/dd[5]/a").click()
                        Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"借款编号")
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(borrowid)
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                        # 进入初审页面
                        driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr/td/a[1]").click()
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/aside/label[1]/input").click()
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[2]/aside/textarea").send_keys(u"审核审核")
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[3]/aside/span[1]/a").click()
                        time.sleep(3)
                        Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"借款编号")
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(borrowid)
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                        # 提交二审
                        driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr[1]/td/a[1]").click()
                        driver.find_element_by_xpath(".//*[@id='form1']/ul[3]/li/aside/span[1]/a").click()
                        time.sleep(3)
                        Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"借款编号")
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(borrowid)
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                        driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr/td/a[1]").click()
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/aside/label[1]/input").click()
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[2]/aside/textarea").send_keys(u"审核审核")
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[3]/aside/span[1]/a").click()
                        # 执行发标连接，进入投资中的借款
                        driver.get("http://task.yidai.co/worthautoissue.task.php")
                        time.sleep(2)
                        driver.refresh()
                        driver.quit()
                        return u"借款标题是：" + borrowtitle + now + u",借款人是：" + borrowname + u"，借款编号是：" + borrowid
                    if b == False:
                        driver.quit()
                        return u"发标失败"
                if a == False:
                    driver.quit()
                    return u"登录失败"
                #为房东乐时
                if borrow_type1 == u"3":
                    if username_type == u"机构":
                        #driver.find_element_by_id("weituo_ren").send_keys(u"511324199412270492")
                        #driver.find_element_by_id("wtUpload").send_keys("D:\\photo\\1.jpg")
                        Select(driver.find_element_by_id("borrow_use")).select_by_visible_text(u"临时周转")
                        driver.find_element_by_id("account").send_keys(money)
                        driver.find_element_by_xpath(".//*[@id='borrow_style_box']/label[" + huankuanfangshi + "]/input").click()
                        Select(driver.find_element_by_id("borrow_period")).select_by_visible_text(month)
                        time.sleep(2)
                        driver.find_element_by_id("borrow_apr").clear()
                        driver.find_element_by_id("borrow_apr").send_keys(rate)
                        Select(driver.find_element_by_xpath(".//*[@id='cashgroup']")).select_by_visible_text(cashgroup)
                        driver.find_element_by_id("agent_username").send_keys(agentname)
                        driver.find_element_by_link_text(u"下一步").click()
                        driver.switch_to_alert().accept()
                        # driver.find_element_by_xpath(".//*[@id='form1']/ul/li[6]/aside/input").send_keys(u"陈强")
                        Select(driver.find_element_by_id("category")).select_by_visible_text(u"其他")
                        driver.find_element_by_id("account_use").send_keys(u"借钱来耍耍")
                        driver.find_element_by_link_text(u"下一步").click()
                    if username_type == u"个人" :
                        Select(driver.find_element_by_id("borrow_use")).select_by_visible_text(u"临时周转")
                        driver.find_element_by_id("account").send_keys(money)
                        driver.find_element_by_xpath(".//*[@id='borrow_style_box']/label[" + huankuanfangshi + "]/input").click()
                        Select(driver.find_element_by_id("borrow_period")).select_by_visible_text(month)
                        time.sleep(2)
                        driver.find_element_by_id("borrow_apr").clear()
                        driver.find_element_by_id("borrow_apr").send_keys(rate)
                        Select(driver.find_element_by_xpath(".//*[@id='cashgroup']")).select_by_visible_text(cashgroup)
                        driver.find_element_by_id("agent_username").send_keys(agentname)
                        driver.find_element_by_link_text(u"下一步").click()
                        driver.switch_to_alert().accept()
                        # 第二个页面
                        #选择房东乐A或者B   1为A，2为B
                        driver.find_element_by_xpath("//*[@id='form1']/ul[1]/li[1]/aside/label[1]/input").click()
                        Select(driver.find_element_by_id("edu")).select_by_visible_text(u"本科")
                        driver.find_element_by_xpath(".//*[@id='form1']/ul[2]/li[6]/aside/label[1]/input").click()
                        driver.find_element_by_xpath(".//*[@id='form1']/ul[2]/li[7]/aside/input").send_keys(u"四川省南充市")
                        driver.find_element_by_xpath(".//*[@id='form1']/ul[2]/li[8]/aside/input").send_keys(u"四川省成都市青羊区")
                        Select(driver.find_element_by_id("category")).select_by_visible_text(u"其他")
                        driver.find_element_by_id("account_use").send_keys(u"借钱来耍耍")
                        Select(driver.find_element_by_id("province")).select_by_visible_text(u"四川省")
                        Select(driver.find_element_by_id("city")).select_by_visible_text(u"成都")
                        driver.find_element_by_id("work_info").send_keys(u"工作很好，工资很高")
                        driver.find_element_by_link_text(u"下一步").click()
                    # 进入发标第三个页面
                    # 切换iframe
                    driver.switch_to.frame("iframebox1")
                    Select(driver.find_element_by_xpath(".//*[@id='house_type']")).select_by_visible_text(u"商品房")
                    driver.find_element_by_xpath(".//*[@id='house']/li[3]/aside/label[1]/input").click()
                    driver.find_element_by_xpath(".//*[@id='house']/li[5]/aside/input").send_keys(u"2015-07-25")
                    Select(driver.find_element_by_id("house_live_type")).select_by_visible_text(u"套一")
                    Select(driver.find_element_by_id("house_zxqk")).select_by_visible_text(u"精装")
                    driver.find_element_by_xpath(".//*[@id='house']/li[8]/aside/input").send_keys(u"100")
                    driver.find_element_by_xpath(".//*[@id='house']/li[9]/aside/input").send_keys(u"成都长富新城")
                    driver.find_element_by_xpath(".//*[@id='house']/li[10]/aside/input").send_keys(u"房子不错")
                    driver.find_element_by_id("house_money").send_keys(u"100")
                    driver.find_element_by_id("house_area").send_keys(u"100")
                    driver.find_element_by_id("house_address").send_keys(u"成都市天府广场" + now)
                    driver.find_element_by_id("house_byuser").send_keys(u"陈强")
                    Select(driver.find_element_by_id("house_byuser_type")).select_by_visible_text(u"单独所有")
                    driver.find_element_by_xpath(".//*[@id='house']/li[16]/aside/input").send_keys(u"王爆炸")
                    Select(driver.find_element_by_id("house_card_type")).select_by_visible_text(u"产权证")
                    driver.find_element_by_xpath(".//*[@id='house']/li[18]/aside/input").send_keys(now)
                    driver.find_element_by_xpath(".//*[@id='house']/li[19]/aside/input").send_keys(u"1000")
                    driver.find_element_by_xpath(".//*[@id='house']/li[20]/aside/input").send_keys(u"1200")
                    driver.find_element_by_xpath(".//*[@id='house']/li[21]/aside/input").send_keys(u"陈强")
                    driver.find_element_by_xpath(".//*[@id='house']/li[22]/aside/input").send_keys(u"20000")
                    driver.find_element_by_xpath(".//*[@id='house']/li[23]/aside/input[1]").send_keys(u"2017-07-25")
                    driver.find_element_by_xpath(".//*[@id='house']/li[23]/aside/input[2]").send_keys(u"2018-07-25")
                    driver.find_element_by_xpath(".//*[@id='house']/li[24]/aside/input").send_keys(u"天宸汇力商业保理（深圳）有限公司")
                    driver.find_element_by_xpath(".//*[@id='house']/li[25]/aside/input").send_keys(u"2015-09-04")
                    driver.switch_to.default_content()
                    driver.find_element_by_xpath("//*[@id='form1']/ul[2]/li[6]/aside/input[4]").click()
                    # 进入发标第四个页面,并判断是否有奖励标
                    '''driver.find_element_by_xpath(
                        ".//*[@id='house']/li[2]/aside/label[" + rewardstate + "]/input").click()
                    # rewardstate为1时为无奖励
                    if rewardstate == "1":
                        driver.find_element_by_xpath(".//*[@id='house']/li[9]/aside/input").click()
                        # 切换iframe
                        WebElementframe = driver.find_element_by_xpath("html/body/div/iframe")
                        driver.switch_to.frame(WebElementframe)
                        driver.find_element_by_id("dpTodayInput").click()
                        driver.switch_to.default_content()
                    # rewardstate为2时为有奖励
                    if rewardstate == "2":
                        driver.find_element_by_xpath(
                            ".//*[@id='status_type']/aside/label[" + rewardmode + "]/input").click()
                        # rewardmode为1时为现金奖励
                        if rewardmode == "1":
                            driver.find_element_by_xpath(".//*[@id='status_1']/aside/input").send_keys(reward)
                            driver.find_element_by_xpath(".//*[@id='house']/li[9]/aside/input").click()
                            # 切换iframe
                            WebElementframe = driver.find_element_by_xpath("html/body/div/iframe")
                            driver.switch_to.frame(WebElementframe)
                            driver.find_element_by_id("dpTodayInput").click()
                            driver.switch_to.default_content()
                        # rewardmode为2时为按投资金额比例奖励
                        if rewardmode == "2":
                            driver.find_element_by_xpath(".//*[@id='status_2']/aside/input").send_keys(reward)
                            driver.find_element_by_xpath(".//*[@id='house']/li[9]/aside/input").click()
                            # 切换iframe
                            WebElementframe = driver.find_element_by_xpath("html/body/div/iframe")
                            driver.switch_to.frame(WebElementframe)
                            driver.find_element_by_id("dpTodayInput").click()
                            driver.switch_to.default_content()
                    # driver.find_element_by_xpath(".//*[@id='house']/li[9]/aside/input").send_keys(u"2017-09-05 10:40")
                    # 截图并保存
                    # pic_path = 'D:\\python-photo\\image\\' + now + 'FDL-biao' + '.png'  # 截图保存路径
                    # print pic_path
                    # driver.save_screenshot(pic_path)  # 截图
                    '''
                    #time.sleep(2)
                    #driver.find_element_by_xpath(".//*[@id='form1']/ul[3]/li/aside/span[1]/a").click()
                    # 判断是否发布标的成功
                    # 根据业务编号进行搜索标，并进行审核
                    driver.find_element_by_xpath(".//*[@id='subnav']/dl/dd[5]/a").click()
                    Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"业务编号")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(now)
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                    # 判断是否发布成功
                    try:
                        driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr/td/a[1]")
                        b = True
                    except:
                        b = False
                    if b == True:
                        borrowid = driver.find_element_by_xpath(".//*[@id='tabScroll']/div/table/tbody/tr/td[1]").text
                        print u"借款编号是：" + borrowid
                        # 进行第一次审核
                        driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr/td/a[1]").click()
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/aside/label[1]/input").click()
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[2]/aside/textarea").send_keys(u"审核成功")
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[3]/aside/span[1]/a").click()
                        # 按照业务编号进行搜索标
                        driver.find_element_by_xpath(".//*[@id='subnav']/dl/dd[5]/a").click()
                        Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"业务编号")
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(now)
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                        # 进行第二次审核
                        driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr/td/a[1]").click()
                        driver.find_element_by_xpath(".//*[@id='form1']/ul[3]/li/aside/span[1]/a").click()
                        # 按照业务编号进行搜索标
                        driver.find_element_by_xpath(".//*[@id='subnav']/dl/dd[5]/a").click()
                        Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"业务编号")
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(now)
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                        # 进行第三次审核
                        driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr/td/a[1]").click()
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/aside/label[1]/input").click()
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[2]/aside/textarea").send_keys(u"审核成功")
                        driver.find_element_by_xpath(".//*[@id='form1']/ul/li[3]/aside/span[1]/a").click()
                        # 初审完毕，执行发标计划任务，进入投资中的借款
                        driver.get("http://task.yidai.co/worthautoissue.task.php")
                        time.sleep(2)
                        driver.quit()
                        return u"借款标题是：" + borrowtitle + now + u",借款人是：" + borrowname + u"，借款编号是：" + borrowid
        #为定向标时
        if borrow_type == u"2":
            # 为车易贷时
            if borrow_type1 == u"1":
                if username_type == u"机构":
                    #driver.find_element_by_id("weituo_ren").send_keys(u"511324199412270492")
                    #driver.find_element_by_id("wtUpload").send_keys("D:\\photo\\1.jpg")
                    Select(driver.find_element_by_id("borrow_use")).select_by_visible_text(u"临时周转")
                    driver.find_element_by_id("account").send_keys(money)
                    driver.find_element_by_xpath(".//*[@id='borrow_style_box']/label[" + huankuanfangshi + "]/input").click()
                    Select(driver.find_element_by_id("borrow_period")).select_by_visible_text(month)
                    time.sleep(2)
                    driver.find_element_by_id("borrow_apr").clear()
                    driver.find_element_by_id("borrow_apr").send_keys(rate)
                    Select(driver.find_element_by_xpath(".//*[@id='cashgroup']")).select_by_visible_text(cashgroup)
                    driver.find_element_by_id("agent_username").send_keys(agentname)
                    driver.find_element_by_link_text(u"下一步").click()
                    driver.switch_to_alert().accept()
                    # driver.find_element_by_xpath(".//*[@id='form1']/ul/li[6]/aside/input").send_keys(u"陈强")
                    Select(driver.find_element_by_id("category")).select_by_visible_text(u"其他")
                    driver.find_element_by_id("account_use").send_keys(u"借钱来耍耍")
                    driver.find_element_by_link_text(u"下一步").click()
                if username_type == u"个人":
                    Select(driver.find_element_by_id("borrow_use")).select_by_visible_text(u"临时周转")
                    driver.find_element_by_id("account").send_keys(money)
                    driver.find_element_by_xpath(".//*[@id='borrow_style_box']/label[" + huankuanfangshi + "]/input").click()
                    Select(driver.find_element_by_id("borrow_period")).select_by_visible_text(month)
                    time.sleep(2)
                    driver.find_element_by_id("borrow_apr").clear()
                    driver.find_element_by_id("borrow_apr").send_keys(rate)
                    Select(driver.find_element_by_xpath(".//*[@id='cashgroup']")).select_by_visible_text(cashgroup)
                    driver.find_element_by_id("agent_username").send_keys(agentname)
                    driver.find_element_by_link_text(u"下一步").click()
                    driver.switch_to_alert().accept()
                    # 第二个页面
                    Select(driver.find_element_by_id("edu")).select_by_visible_text(u"本科")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul[2]/li[6]/aside/label[1]/input").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul[2]/li[7]/aside/input").send_keys(u"四川省南充市")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul[2]/li[8]/aside/input").send_keys(u"四川省成都市青羊区")
                    Select(driver.find_element_by_id("category")).select_by_visible_text(u"其他")
                    driver.find_element_by_id("account_use").send_keys(u"借钱来耍耍")
                    Select(driver.find_element_by_id("province")).select_by_visible_text(u"四川省")
                    Select(driver.find_element_by_id("city")).select_by_visible_text(u"成都")
                    driver.find_element_by_id("work_info").send_keys(u"工作很好，工资很高")
                    driver.find_element_by_link_text(u"下一步").click()
                driver.find_element_by_xpath(".//*[@id='car']/li[2]/aside/label[1]/input").click()
                driver.find_element_by_xpath(".//*[@id='car']/li[3]/aside/label[1]/input").click()
                driver.find_element_by_xpath(".//*[@id='car']/li[7]/aside/input").send_keys(u"100")
                driver.find_element_by_xpath(".//*[@id='car']/li[12]/aside/input").send_keys(now)
                driver.find_element_by_xpath(".//*[@id='form1']/ul[6]/li[5]/aside/input[5]").click()
                driver.find_element_by_link_text(u"提交").click()
                # 判断是否发布标的成功
                # 进入标的批次号管理页面查看是否发布成功
                driver.find_element_by_xpath(".//*[@id='subnav']/dl/dd[22]/a").click()
                Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"业务编号")
                driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(now)
                driver.find_element_by_xpath(".//*[@id='form1']/ul/li[2]/a").click()
                try:
                    driver.find_element_by_xpath(".//*[@id='yfm']")
                    b = True
                except:
                    b = False
                if b == True:
                    text = driver.find_element_by_xpath(".//*[@id='yfm']").text
                    borrowid = driver.find_element_by_xpath(".//*[@id='tabScroll']/div/table/tbody/tr/td[2]").text
                    driver.find_element_by_xpath(
                        ".//*[@id='tabScroll']/div/table/tbody/tr[1]/td[1]/input").click()  # 勾选第一个标的进行生成批次号
                    driver.find_element_by_xpath("html/body/main/section/div[2]/a").click()
                    time.sleep(2)
                    driver.find_element_by_xpath(".//*[@id='form_yhk']/ul/li[4]/input[1]").click()
                    time.sleep(2)
                    driver.find_element_by_xpath(".//*[@id='form_yhk']/ul/li[3]/input[2]").click()
                    # 再次搜索对应用户名的标
                    Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"业务编号")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(now)
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[2]/a").click()
                    driver.find_element_by_xpath(".//*[@id='tabScroll']/div/table/tbody/tr/td[1]/input").click()
                    driver.find_element_by_xpath("html/body/main/section/div[2]/a[2]").click()
                    time.sleep(2)
                    driver.find_element_by_xpath(u"(//input[@value='确定'])[2]").click()
                    driver.refresh()
                    # 进入标的初审页面,并按照借款编号进行搜索标的
                    time.sleep(2)
                    driver.find_element_by_xpath(".//*[@id='subnav']/dl/dd[5]/a").click()
                    Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"借款编号")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(borrowid)
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                    # 进入初审页面
                    driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr/td/a[1]").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[2]/aside/label[1]/input").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[3]/aside/textarea").send_keys(u"审核审核")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/aside/span[1]/a").click()
                    time.sleep(3)
                    Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"借款编号")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(borrowid)
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                    # 提交二审
                    driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr[1]/td/a[1]").click()
                    #选择标的分配：1为宝宝，2为微理财
                    driver.find_element_by_xpath(".//*[@id='wbpid']/label["+biaofenpei+"]/input").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul[3]/li/aside/span[1]/a").click()
                    time.sleep(3)
                    Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"借款编号")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(borrowid)
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                    driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr/td/a[1]").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[2]/aside/label[1]/input").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[3]/aside/textarea").send_keys(u"审核审核")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/aside/span[1]/a").click()
                    # 执行发标连接，进入投资中的借款
                    driver.get("http://task.yidai.co/worthautoissue.task.php")
                    time.sleep(2)
                    driver.refresh()
                    driver.quit()
                    return u"借款标题是：" + borrowtitle + now + u",借款人是：" + borrowname + u"，借款编号是：" + borrowid
                if b == False:
                    driver.quit()
                    return u"发标失败"
            if a == False:
                driver.quit()
                return u"登录失败"
            # 为房易贷时
            if borrow_type1 == u"2":
                if username_type == u"机构":
                    #driver.find_element_by_id("weituo_ren").send_keys(u"511324199412270492")
                    #driver.find_element_by_id("wtUpload").send_keys("D:\\photo\\1.jpg")
                    Select(driver.find_element_by_id("borrow_use")).select_by_visible_text(u"临时周转")
                    driver.find_element_by_id("account").send_keys(money)
                    driver.find_element_by_xpath(
                        ".//*[@id='borrow_style_box']/label[" + huankuanfangshi + "]/input").click()
                    Select(driver.find_element_by_id("borrow_period")).select_by_visible_text(month)
                    time.sleep(2)
                    driver.find_element_by_id("borrow_apr").clear()
                    driver.find_element_by_id("borrow_apr").send_keys(rate)
                    Select(driver.find_element_by_xpath(".//*[@id='cashgroup']")).select_by_visible_text(cashgroup)
                    driver.find_element_by_id("agent_username").send_keys(agentname)
                    driver.find_element_by_link_text(u"下一步").click()
                    driver.switch_to_alert().accept()
                    # driver.find_element_by_xpath(".//*[@id='form1']/ul/li[6]/aside/input").send_keys(u"陈强")
                    Select(driver.find_element_by_id("category")).select_by_visible_text(u"其他")
                    driver.find_element_by_id("account_use").send_keys(u"借钱来耍耍")
                    driver.find_element_by_link_text(u"下一步").click()
                if username_type == u"个人":
                    Select(driver.find_element_by_id("borrow_use")).select_by_visible_text(u"临时周转")
                    driver.find_element_by_id("account").send_keys(money)
                    driver.find_element_by_xpath(
                        ".//*[@id='borrow_style_box']/label[" + huankuanfangshi + "]/input").click()
                    Select(driver.find_element_by_id("borrow_period")).select_by_visible_text(month)
                    time.sleep(2)
                    driver.find_element_by_id("borrow_apr").clear()
                    driver.find_element_by_id("borrow_apr").send_keys(rate)
                    Select(driver.find_element_by_xpath(".//*[@id='cashgroup']")).select_by_visible_text(cashgroup)
                    driver.find_element_by_id("agent_username").send_keys(agentname)
                    driver.find_element_by_link_text(u"下一步").click()
                    driver.switch_to_alert().accept()
                    # 第二个页面
                    Select(driver.find_element_by_id("edu")).select_by_visible_text(u"本科")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul[2]/li[6]/aside/label[1]/input").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul[2]/li[7]/aside/input").send_keys(u"四川省南充市")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul[2]/li[8]/aside/input").send_keys(u"四川省成都市青羊区")
                    Select(driver.find_element_by_id("category")).select_by_visible_text(u"其他")
                    driver.find_element_by_id("account_use").send_keys(u"借钱来耍耍")
                    Select(driver.find_element_by_id("province")).select_by_visible_text(u"四川省")
                    Select(driver.find_element_by_id("city")).select_by_visible_text(u"成都")
                    driver.find_element_by_id("work_info").send_keys(u"工作很好，工资很高")
                    driver.find_element_by_link_text(u"下一步").click()
                # 进入发标第三个页面
                # 切换iframe
                driver.switch_to.frame("iframebox1")
                Select(driver.find_element_by_xpath(".//*[@id='house_type']")).select_by_visible_text(u"商品房")
                driver.find_element_by_xpath(".//*[@id='house']/li[3]/aside/label[1]/input").click()
                driver.find_element_by_xpath(".//*[@id='house']/li[5]/aside/input").send_keys(u"2015-07-25")
                driver.find_element_by_xpath(".//*[@id='house']/li[6]/aside/input").send_keys(u"100")
                driver.find_element_by_xpath(".//*[@id='house']/li[8]/aside/input").send_keys(u"成都市公证处")
                driver.find_element_by_id("house_money").send_keys(u"100")
                driver.find_element_by_id("house_area").send_keys(u"100")
                driver.find_element_by_id("house_address").send_keys(u"成都市天府广场")
                driver.find_element_by_id("house_byuser").send_keys(u"陈强")
                Select(driver.find_element_by_id("house_byuser_type")).select_by_visible_text(u"单独所有")
                driver.find_element_by_xpath(".//*[@id='house']/li[14]/aside/input").send_keys(now)
                driver.switch_to.default_content()
                driver.find_element_by_xpath(".//*[@id='form1']/ul[2]/li[5]/aside/input[6]").click()
                time.sleep(2)
                driver.find_element_by_xpath(".//*[@id='form1']/ul[3]/li/aside/span[1]/a").click()
                # 判断是否发布标的成功
                # 进入标的批次号管理页面查看是否发布成功
                driver.find_element_by_xpath(".//*[@id='subnav']/dl/dd[22]/a").click()
                Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"业务编号")
                driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(now)
                driver.find_element_by_xpath(".//*[@id='form1']/ul/li[2]/a").click()
                try:
                    driver.find_element_by_xpath(".//*[@id='yfm']")
                    b = True
                except:
                    b = False
                if b == True:
                    text = driver.find_element_by_xpath(".//*[@id='yfm']").text
                    borrowid = driver.find_element_by_xpath(".//*[@id='tabScroll']/div/table/tbody/tr/td[2]").text
                    driver.find_element_by_xpath(
                        ".//*[@id='tabScroll']/div/table/tbody/tr[1]/td[1]/input").click()  # 勾选第一个标的进行生成批次号
                    driver.find_element_by_xpath("html/body/main/section/div[2]/a").click()
                    time.sleep(2)
                    driver.find_element_by_xpath(".//*[@id='form_yhk']/ul/li[4]/input[1]").click()
                    time.sleep(2)
                    driver.find_element_by_xpath(".//*[@id='form_yhk']/ul/li[3]/input[2]").click()
                    # 再次搜索对应用户名的标
                    Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"业务编号")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(now)
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[2]/a").click()
                    driver.find_element_by_xpath(".//*[@id='tabScroll']/div/table/tbody/tr/td[1]/input").click()
                    driver.find_element_by_xpath("html/body/main/section/div[2]/a[2]").click()
                    time.sleep(2)
                    driver.find_element_by_xpath(u"(//input[@value='确定'])[2]").click()
                    driver.refresh()
                    # 进入标的初审页面,并按照借款编号进行搜索标的
                    time.sleep(2)
                    driver.find_element_by_xpath(".//*[@id='subnav']/dl/dd[5]/a").click()
                    Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"借款编号")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(borrowid)
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                    # 进入初审页面
                    driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr/td/a[1]").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[2]/aside/label[1]/input").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[3]/aside/textarea").send_keys(u"审核审核")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/aside/span[1]/a").click()
                    time.sleep(3)
                    Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"借款编号")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(borrowid)
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                    # 提交二审
                    driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr[1]/td/a[1]").click()
                    # 选择标的分配：1为宝宝，2为微理财
                    driver.find_element_by_xpath(".//*[@id='wbpid']/label[" + biaofenpei + "]/input").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul[3]/li/aside/span[1]/a").click()
                    time.sleep(3)
                    Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"借款编号")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(borrowid)
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                    driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr/td/a[1]").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[2]/aside/label[1]/input").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[3]/aside/textarea").send_keys(u"审核审核")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/aside/span[1]/a").click()
                    # 执行发标连接，进入投资中的借款
                    driver.get("http://task.yidai.co/worthautoissue.task.php")
                    time.sleep(2)
                    driver.refresh()
                    driver.quit()
                    return u"借款标题是：" + borrowtitle + now + u",借款人是：" + borrowname + u"，借款编号是：" + borrowid
                if b == False:
                    driver.quit()
                    return u"发标失败"
            if a == False:
                driver.quit()
                return u"登录失败"
            # 为房东乐时
            if borrow_type1 == u"3":
                if username_type == u"机构":
                    #driver.find_element_by_id("weituo_ren").send_keys(u"511324199412270492")
                    #driver.find_element_by_id("wtUpload").send_keys("D:\\photo\\1.jpg")
                    Select(driver.find_element_by_id("borrow_use")).select_by_visible_text(u"临时周转")
                    driver.find_element_by_id("account").send_keys(money)
                    driver.find_element_by_xpath(
                        ".//*[@id='borrow_style_box']/label[" + huankuanfangshi + "]/input").click()
                    Select(driver.find_element_by_id("borrow_period")).select_by_visible_text(month)
                    time.sleep(2)
                    driver.find_element_by_id("borrow_apr").clear()
                    driver.find_element_by_id("borrow_apr").send_keys(rate)
                    Select(driver.find_element_by_xpath(".//*[@id='cashgroup']")).select_by_visible_text(cashgroup)
                    driver.find_element_by_id("agent_username").send_keys(agentname)
                    driver.find_element_by_link_text(u"下一步").click()
                    driver.switch_to_alert().accept()
                    # driver.find_element_by_xpath(".//*[@id='form1']/ul/li[6]/aside/input").send_keys(u"陈强")
                    Select(driver.find_element_by_id("category")).select_by_visible_text(u"其他")
                    driver.find_element_by_id("account_use").send_keys(u"借钱来耍耍")
                    driver.find_element_by_link_text(u"下一步").click()
                if username_type == u"个人":
                    Select(driver.find_element_by_id("borrow_use")).select_by_visible_text(u"临时周转")
                    driver.find_element_by_id("account").send_keys(money)
                    driver.find_element_by_xpath(".//*[@id='borrow_style_box']/label[" + huankuanfangshi + "]/input").click()
                    Select(driver.find_element_by_id("borrow_period")).select_by_visible_text(month)
                    time.sleep(2)
                    driver.find_element_by_id("borrow_apr").clear()
                    driver.find_element_by_id("borrow_apr").send_keys(rate)
                    Select(driver.find_element_by_xpath(".//*[@id='cashgroup']")).select_by_visible_text(cashgroup)
                    driver.find_element_by_id("agent_username").send_keys(agentname)
                    driver.find_element_by_link_text(u"下一步").click()
                    driver.switch_to_alert().accept()
                    # 第二个页面
                    # 选择房东乐A或者B   1为A，2为B
                    driver.find_element_by_xpath("//*[@id='form1']/ul[1]/li[1]/aside/label[1]/input").click()
                    Select(driver.find_element_by_id("edu")).select_by_visible_text(u"本科")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul[2]/li[6]/aside/label[1]/input").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul[2]/li[7]/aside/input").send_keys(u"四川省南充市")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul[2]/li[8]/aside/input").send_keys(u"四川省成都市青羊区")
                    Select(driver.find_element_by_id("category")).select_by_visible_text(u"其他")
                    driver.find_element_by_id("account_use").send_keys(u"借钱来耍耍")
                    Select(driver.find_element_by_id("province")).select_by_visible_text(u"四川省")
                    Select(driver.find_element_by_id("city")).select_by_visible_text(u"成都")
                    driver.find_element_by_id("work_info").send_keys(u"工作很好，工资很高")
                    driver.find_element_by_link_text(u"下一步").click()
                # 进入发标第三个页面
                # 切换iframe
                driver.switch_to.frame("iframebox1")
                Select(driver.find_element_by_xpath(".//*[@id='house_type']")).select_by_visible_text(u"商品房")
                driver.find_element_by_xpath(".//*[@id='house']/li[3]/aside/label[1]/input").click()
                driver.find_element_by_xpath(".//*[@id='house']/li[5]/aside/input").send_keys(u"2015-07-25")
                Select(driver.find_element_by_id("house_live_type")).select_by_visible_text(u"套一")
                Select(driver.find_element_by_id("house_zxqk")).select_by_visible_text(u"精装")
                driver.find_element_by_xpath(".//*[@id='house']/li[8]/aside/input").send_keys(u"100")
                driver.find_element_by_xpath(".//*[@id='house']/li[9]/aside/input").send_keys(u"成都长富新城")
                driver.find_element_by_xpath(".//*[@id='house']/li[10]/aside/input").send_keys(u"房子不错")
                driver.find_element_by_id("house_money").send_keys(u"100")
                driver.find_element_by_id("house_area").send_keys(u"100")
                driver.find_element_by_id("house_address").send_keys(u"成都市天府广场" + now)
                driver.find_element_by_id("house_byuser").send_keys(u"陈强")
                Select(driver.find_element_by_id("house_byuser_type")).select_by_visible_text(u"单独所有")
                driver.find_element_by_xpath(".//*[@id='house']/li[16]/aside/input").send_keys(u"王爆炸")
                Select(driver.find_element_by_id("house_card_type")).select_by_visible_text(u"产权证")
                driver.find_element_by_xpath(".//*[@id='house']/li[18]/aside/input").send_keys(now)
                driver.find_element_by_xpath(".//*[@id='house']/li[19]/aside/input").send_keys(u"1000")
                driver.find_element_by_xpath(".//*[@id='house']/li[20]/aside/input").send_keys(u"1200")
                driver.find_element_by_xpath(".//*[@id='house']/li[21]/aside/input").send_keys(u"陈强")
                driver.find_element_by_xpath(".//*[@id='house']/li[22]/aside/input").send_keys(u"20000")
                driver.find_element_by_xpath(".//*[@id='house']/li[23]/aside/input[1]").send_keys(u"2017-07-25")
                driver.find_element_by_xpath(".//*[@id='house']/li[23]/aside/input[2]").send_keys(u"2018-07-25")
                driver.find_element_by_xpath(".//*[@id='house']/li[24]/aside/input").send_keys(u"天宸汇力商业保理（深圳）有限公司")
                driver.find_element_by_xpath(".//*[@id='house']/li[25]/aside/input").send_keys(u"2015-09-04")
                driver.switch_to.default_content()
                driver.find_element_by_xpath("//*[@id='form1']/ul[2]/li[6]/aside/input[4]").click()
                # 进入发标第四个页面,并判断是否有奖励标
                '''driver.find_element_by_xpath(
                    ".//*[@id='house']/li[2]/aside/label[" + rewardstate + "]/input").click()
                # rewardstate为1时为无奖励
                if rewardstate == "1":
                    driver.find_element_by_xpath(".//*[@id='house']/li[9]/aside/input").click()
                    # 切换iframe
                    WebElementframe = driver.find_element_by_xpath("html/body/div/iframe")
                    driver.switch_to.frame(WebElementframe)
                    driver.find_element_by_id("dpTodayInput").click()
                    driver.switch_to.default_content()
                # rewardstate为2时为有奖励
                if rewardstate == "2":
                    driver.find_element_by_xpath(
                        ".//*[@id='status_type']/aside/label[" + rewardmode + "]/input").click()
                    # rewardmode为1时为现金奖励
                    if rewardmode == "1":
                        driver.find_element_by_xpath(".//*[@id='status_1']/aside/input").send_keys(reward)
                        driver.find_element_by_xpath(".//*[@id='house']/li[9]/aside/input").click()
                        # 切换iframe
                        WebElementframe = driver.find_element_by_xpath("html/body/div/iframe")
                        driver.switch_to.frame(WebElementframe)
                        driver.find_element_by_id("dpTodayInput").click()
                        driver.switch_to.default_content()
                    # rewardmode为2时为按投资金额比例奖励
                    if rewardmode == "2":
                        driver.find_element_by_xpath(".//*[@id='status_2']/aside/input").send_keys(reward)
                        driver.find_element_by_xpath(".//*[@id='house']/li[9]/aside/input").click()
                        # 切换iframe
                        WebElementframe = driver.find_element_by_xpath("html/body/div/iframe")
                        driver.switch_to.frame(WebElementframe)
                        driver.find_element_by_id("dpTodayInput").click()
                        driver.switch_to.default_content()
                # driver.find_element_by_xpath(".//*[@id='house']/li[9]/aside/input").send_keys(u"2017-09-05 10:40")
                # 截图并保存
                # pic_path = 'D:\\python-photo\\image\\' + now + 'FDL-biao' + '.png'  # 截图保存路径
                # print pic_path
                # driver.save_screenshot(pic_path)  # 截图
                '''
                # time.sleep(2)
                # driver.find_element_by_xpath(".//*[@id='form1']/ul[3]/li/aside/span[1]/a").click()
                # 判断是否发布标的成功
                # 根据业务编号进行搜索标，并进行审核
                driver.find_element_by_xpath(".//*[@id='subnav']/dl/dd[5]/a").click()
                Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"业务编号")
                driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(now)
                driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                # 判断是否发布成功
                try:
                    driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr/td/a[1]")
                    b = True
                except:
                    b = False
                if b == True:
                    borrowid = driver.find_element_by_xpath(".//*[@id='tabScroll']/div/table/tbody/tr/td[1]").text
                    print u"借款编号是：" + borrowid
                    # 进行第一次审核
                    driver.find_element_by_xpath(".//*[@id='subnav']/dl/dd[5]/a").click()
                    Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"借款编号")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(borrowid)
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                    # 进入初审页面
                    driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr/td/a[1]").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[2]/aside/label[1]/input").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[3]/aside/textarea").send_keys(u"审核审核")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/aside/span[1]/a").click()
                    time.sleep(3)
                    Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"借款编号")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(borrowid)
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                    # 提交二审
                    driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr[1]/td/a[1]").click()
                    # 选择标的分配：1为宝宝，2为微理财
                    driver.find_element_by_xpath(".//*[@id='wbpid']/label[" + biaofenpei + "]/input").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul[3]/li/aside/span[1]/a").click()
                    time.sleep(3)
                    Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"借款编号")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(borrowid)
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                    driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr/td/a[1]").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[2]/aside/label[1]/input").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[3]/aside/textarea").send_keys(u"审核审核")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/aside/span[1]/a").click()
                    # 初审完毕，执行发标计划任务，进入投资中的借款
                    driver.get("http://task.yidai.co/worthautoissue.task.php")
                    time.sleep(2)
                    driver.quit()
                    #为车商贷时
            if borrow_type1 == u"4":
                Select(driver.find_element_by_id("borrow_use")).select_by_visible_text(u"收购二手车")
                driver.find_element_by_id("account").send_keys(money)
                driver.find_element_by_xpath(
                    ".//*[@id='borrow_style_box']/label[" + huankuanfangshi + "]/input").click()
                Select(driver.find_element_by_id("borrow_period")).select_by_visible_text(month)
                time.sleep(2)
                driver.find_element_by_id("borrow_apr").clear()
                driver.find_element_by_id("borrow_apr").send_keys(rate)
                Select(driver.find_element_by_xpath(".//*[@id='cashgroup']")).select_by_visible_text(cashgroup)
                driver.find_element_by_id("agent_username").send_keys(agentname)
                driver.find_element_by_link_text(u"下一步").click()
                driver.switch_to_alert().accept()
                driver.find_element_by_xpath(".//*[@id='form1']/ul/li[7]/aside/input").send_keys(u"陈强")
                Select(driver.find_element_by_id("category")).select_by_visible_text(u"其他")
                driver.find_element_by_id("account_use").send_keys(u"借钱来耍耍")
                driver.find_element_by_link_text(u"下一步").click()
                driver.find_element_by_xpath(".//*[@id='csd']/li[1]/aside/input").send_keys(u"10")
                driver.find_element_by_xpath(".//*[@id='csd']/li[2]/aside/input").send_keys(u"1000")
                driver.find_element_by_xpath(".//*[@id='csd']/li[3]/aside/input").send_keys(u"2017-07-25")
                driver.find_element_by_xpath(".//*[@id='csd']/li[4]/aside/input").send_keys(u"10000")
                driver.find_element_by_xpath(".//*[@id='csd']/li[5]/aside/input").send_keys(u"买卖二手车")
                driver.find_element_by_xpath("//*[@id='addtable']").click()
                # 判断是否发布标的成功
                # 根据业务编号进行搜索标，并进行审核
                driver.find_element_by_xpath(".//*[@id='subnav']/dl/dd[5]/a").click()
                Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"业务编号")
                driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(now)
                driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                # 判断是否发布成功
                try:
                    driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr/td/a[1]")
                    b = True
                except:
                    b = False
                if b == True:
                    borrowid = driver.find_element_by_xpath(
                        ".//*[@id='tabScroll']/div/table/tbody/tr/td[1]").text
                    print u"借款编号是：" + borrowid
                    # 进行第一次审核
                    driver.find_element_by_xpath(".//*[@id='subnav']/dl/dd[5]/a").click()
                    Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"借款编号")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(borrowid)
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                    # 进入初审页面
                    driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr/td/a[1]").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[2]/aside/label[1]/input").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[3]/aside/textarea").send_keys(u"审核审核")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/aside/span[1]/a").click()
                    time.sleep(3)
                    Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"借款编号")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(borrowid)
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                    # 提交二审
                    driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr[1]/td/a[1]").click()
                    # 选择标的分配：1为宝宝，2为微理财
                    driver.find_element_by_xpath(".//*[@id='wbpid']/label[" + biaofenpei + "]/input").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul[3]/li/aside/span[1]/a").click()
                    time.sleep(3)
                    Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"借款编号")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(borrowid)
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                    driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr/td/a[1]").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[2]/aside/label[1]/input").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[3]/aside/textarea").send_keys(u"审核审核")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/aside/span[1]/a").click()
                    # 初审完毕，执行发标计划任务，进入投资中的借款
                    driver.get("http://task.yidai.co/worthautoissue.task.php")
                    time.sleep(2)
                    driver.quit()
            if borrow_type1 == u"6":
                if username_type == u"机构":
                    #driver.find_element_by_id("weituo_ren").send_keys(u"511324199412270492")
                    #driver.find_element_by_id("wtUpload").send_keys("D:\\photo\\1.jpg")
                    Select(driver.find_element_by_id("borrow_use")).select_by_visible_text(u"临时周转")
                    driver.find_element_by_id("account").send_keys(money)
                    driver.find_element_by_xpath(
                        ".//*[@id='borrow_style_box']/label[" + huankuanfangshi + "]/input").click()
                    Select(driver.find_element_by_id("borrow_period")).select_by_visible_text(month)
                    time.sleep(2)
                    driver.find_element_by_id("borrow_apr").clear()
                    driver.find_element_by_id("borrow_apr").send_keys(rate)
                    Select(driver.find_element_by_xpath(".//*[@id='cashgroup']")).select_by_visible_text(cashgroup)
                    driver.find_element_by_id("agent_username").send_keys(agentname)
                    driver.find_element_by_link_text(u"下一步").click()
                    driver.switch_to_alert().accept()
                    # driver.find_element_by_xpath(".//*[@id='form1']/ul/li[6]/aside/input").send_keys(u"陈强")
                    Select(driver.find_element_by_id("category")).select_by_visible_text(u"其他")
                    driver.find_element_by_id("account_use").send_keys(u"借钱来耍耍")
                    driver.find_element_by_link_text(u"下一步").click()
                if username_type == u"个人":
                    Select(driver.find_element_by_id("borrow_use")).select_by_visible_text(u"临时周转")
                    driver.find_element_by_id("account").send_keys(money)
                    driver.find_element_by_xpath(
                        ".//*[@id='borrow_style_box']/label[" + huankuanfangshi + "]/input").click()
                    Select(driver.find_element_by_id("borrow_period")).select_by_visible_text(month)
                    time.sleep(2)
                    driver.find_element_by_id("borrow_apr").clear()
                    driver.find_element_by_id("borrow_apr").send_keys(rate)
                    Select(driver.find_element_by_xpath(".//*[@id='cashgroup']")).select_by_visible_text(cashgroup)
                    driver.find_element_by_id("agent_username").send_keys(agentname)
                    driver.find_element_by_link_text(u"下一步").click()
                    driver.switch_to_alert().accept()
                    # 第二个页面
                    Select(driver.find_element_by_id("edu")).select_by_visible_text(u"本科")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul[2]/li[6]/aside/label[1]/input").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul[2]/li[7]/aside/input").send_keys(u"四川省南充市")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul[2]/li[8]/aside/input").send_keys(u"四川省成都市青羊区")
                    Select(driver.find_element_by_id("category")).select_by_visible_text(u"其他")
                    driver.find_element_by_id("account_use").send_keys(u"借钱来耍耍")
                    Select(driver.find_element_by_id("province")).select_by_visible_text(u"四川省")
                    Select(driver.find_element_by_id("city")).select_by_visible_text(u"成都")
                    driver.find_element_by_id("work_info").send_keys(u"工作很好，工资很高")
                    driver.find_element_by_link_text(u"下一步").click()
                # 进入发标第三个页面
                # 切换iframe
                driver.switch_to.frame("iframebox1")
                Select(driver.find_element_by_xpath(".//*[@id='house_type']")).select_by_visible_text(u"商品房")
                driver.find_element_by_xpath(".//*[@id='house']/li[3]/aside/label[1]/input").click()
                driver.find_element_by_xpath(".//*[@id='house']/li[5]/aside/input").send_keys(u"2015-07-25")
                driver.find_element_by_xpath(".//*[@id='house']/li[6]/aside/input").send_keys(u"100")
                driver.find_element_by_xpath(".//*[@id='house']/li[8]/aside/input").send_keys(u"成都市公证处")
                driver.find_element_by_id("house_money").send_keys(u"100")
                driver.find_element_by_id("house_area").send_keys(u"100")
                driver.find_element_by_id("house_address").send_keys(u"成都市天府广场")
                driver.find_element_by_id("house_byuser").send_keys(u"陈强")
                Select(driver.find_element_by_id("house_byuser_type")).select_by_visible_text(u"单独所有")
                driver.find_element_by_xpath(".//*[@id='house']/li[14]/aside/input").send_keys(now)
                driver.switch_to.default_content()
                driver.find_element_by_xpath(".//*[@id='form1']/ul[2]/li[5]/aside/input[6]").click()
                time.sleep(2)
                driver.find_element_by_xpath(".//*[@id='form1']/ul[3]/li/aside/span[1]/a").click()
                # 判断是否发布标的成功
                # 进入标的批次号管理页面查看是否发布成功
                driver.find_element_by_xpath(".//*[@id='subnav']/dl/dd[22]/a").click()
                Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"业务编号")
                driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(now)
                driver.find_element_by_xpath(".//*[@id='form1']/ul/li[2]/a").click()
                try:
                    driver.find_element_by_xpath(".//*[@id='yfm']")
                    b = True
                except:
                    b = False
                if b == True:
                    text = driver.find_element_by_xpath(".//*[@id='yfm']").text
                    borrowid = driver.find_element_by_xpath(".//*[@id='tabScroll']/div/table/tbody/tr/td[2]").text
                    driver.find_element_by_xpath(
                        ".//*[@id='tabScroll']/div/table/tbody/tr[1]/td[1]/input").click()  # 勾选第一个标的进行生成批次号
                    driver.find_element_by_xpath("html/body/main/section/div[2]/a").click()
                    time.sleep(2)
                    driver.find_element_by_xpath(".//*[@id='form_yhk']/ul/li[4]/input[1]").click()
                    time.sleep(2)
                    driver.find_element_by_xpath(".//*[@id='form_yhk']/ul/li[3]/input[2]").click()
                    # 再次搜索对应用户名的标
                    Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"业务编号")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(now)
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[2]/a").click()
                    driver.find_element_by_xpath(".//*[@id='tabScroll']/div/table/tbody/tr/td[1]/input").click()
                    driver.find_element_by_xpath("html/body/main/section/div[2]/a[2]").click()
                    time.sleep(2)
                    driver.find_element_by_xpath(u"(//input[@value='确定'])[2]").click()
                    driver.refresh()
                    # 进入标的初审页面,并按照借款编号进行搜索标的
                    time.sleep(2)
                    driver.find_element_by_xpath(".//*[@id='subnav']/dl/dd[5]/a").click()
                    Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"借款编号")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(borrowid)
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                    # 进入初审页面
                    driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr/td/a[1]").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[2]/aside/label[1]/input").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[3]/aside/textarea").send_keys(u"审核审核")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/aside/span[1]/a").click()
                    time.sleep(3)
                    Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"借款编号")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(borrowid)
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                    # 提交二审
                    driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr[1]/td/a[1]").click()
                    # 选择标的分配：1为宝宝，2为微理财
                    driver.find_element_by_xpath(".//*[@id='wbpid']/label[" + biaofenpei + "]/input").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul[3]/li/aside/span[1]/a").click()
                    time.sleep(3)
                    Select(driver.find_element_by_id("searchType")).select_by_visible_text(u"借款编号")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[1]/input").send_keys(borrowid)
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/a").click()
                    driver.find_element_by_xpath(".//*[@id='tabScroll']/table/tbody/tr/td/a[1]").click()
                    driver.find_element_by_xpath("//*[@id='form1']/ul/li[2]/aside/label[1]/input").click()
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[3]/aside/textarea").send_keys(u"审核审核")
                    driver.find_element_by_xpath(".//*[@id='form1']/ul/li[4]/aside/span[1]/a").click()
                    # 执行发标连接，进入投资中的借款
                    driver.get("http://task.yidai.co/worthautoissue.task.php")
                    time.sleep(2)
                    driver.refresh()
                    driver.quit()
                    return u"借款标题是：" + borrowtitle + now + u",借款人是：" + borrowname + u"，借款编号是：" + borrowid
                if b == False:
                    driver.quit()
                    return u"发标失败"
            if a == False:
                driver.quit()
                return u"登录失败"

    return u"借款标题是：" + borrowtitle + now + u",借款人是：" + borrowname + u"，借款编号是：" + borrowid







